-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paper, Ruthie Newman #45
base: master
Are you sure you want to change the base?
Conversation
…ick function to Square component, adds function to mark board with appropriate symbol in response to click.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you know you haven't gotten to detecting the winner yet, but you're pretty close. I left some notes to take a look at. Let me know if you have questions.
const [squares, setSquares] = useState(generateSquares()); | ||
const [currentPlayer, setPlayerState] = useState(PLAYER_1); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also suggest you might want a state variable to keep track of the winner.
} | ||
}) | ||
}) | ||
} | ||
|
||
const checkForWinner = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noting this function is still essentially blank.
I suggest making a loop that goes through the rows checking to see if:
squares[i][0].value === squares[i][1].value and squares[i][0].value === squares[i][2].value
Then do something similar for the columns. The diagonals you have to do manually.
}) | ||
}); | ||
|
||
const squareComponents = flatList.map(data => <Square id={data.id} value={data.value} onClickCallback={onClickCallback} ></Square>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
No description provided.